<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
<ul id="list">  
	<li>1</li>  
	<li>2</li>  
	<li>3</li>  
	<li>4</li>  
	<li>5</li>  
</ul>  
<script>  
	var list_obj = document.getElementsByTagName('li');  
	/*for (var i = 0; i <= list_obj.length; i++) {        
  		list_obj[i].onclick = function() {      
    	alert(i);      
  	}  
}  */
	for (var i = 0; i < list_obj.length; i++) {
		(function(){
			var p=i
			list_obj[i].onclick=function(){
				alert(p+1);
			}
		})();
	}

</script> 
</body>
</html>